using System.Collections.Generic;
using UnityEngine;

namespace Voodoo.Meta.RVModules
{
	public class ChestArea : MonoBehaviour
	{
		public Chest chest;

		public GameObject chestGrid;

		private readonly List<Chest> chests = new List<Chest>();

		public bool IsInitialized => chests.Count > 0;

		public void FillGrid(int numberOfChests, ChestRoomView chestRoomView)
		{
			int num = numberOfChests - chests.Count;
			for (int i = 0; i < num; i++)
			{
				Chest item = Object.Instantiate(chest, chestGrid.transform);
				chests.Add(item);
			}
			float num2 = 0f;
			for (int j = 0; j < chests.Count; j++)
			{
				chests[j].SetUp(num2, chestRoomView);
				num2 += 0.1f;
			}
		}

		public bool IsChestAvailable()
		{
			for (int i = 0; i < chests.Count; i++)
			{
				if (!chests[i].isOpen)
				{
					return true;
				}
			}
			return false;
		}

		public void Clean()
		{
			for (int i = 0; i < chests.Count; i++)
			{
				chests[i].Clean();
			}
		}
	}
}
